//
//  E7FrameInfo.cpp
//  EndlessBattle
//
//  Created by cc on 12-4-28.
//  Copyright (c) 2012年 PalmGame. All rights reserved.
//

#include "E7FrameInfo.h"

CE7FrameInfo::CE7FrameInfo()
{
}

CE7FrameInfo::~CE7FrameInfo()
{
}

void CE7FrameInfo::SetInfo(CCSpriteBatchNode* pSheet, CCRect rcTex, CCPoint pos, float rotate, float scale)
{
    m_eFlag = FT_NORMAL ;
    m_pInfo = CCSprite::spriteWithBatchNode(pSheet, rcTex) ;
    m_pInfo->setPosition(pos) ;
    m_pInfo->setRotation(rotate) ;
    m_pInfo->setScale(scale) ;
    m_pInfo->setIsVisible(false) ;
    pSheet->addChild(m_pInfo) ;
}

void CE7FrameInfo::SetInfo(CCNode* pItem, CCPoint pos, float rotate, float scale, GLbyte alpha)
{
    m_eFlag = FT_SPRITE ;
    m_pItem = pItem ;
    m_pPos = pos ;
    m_fRotate = rotate ;
    m_fScale = scale ;
    m_bAlpha = alpha ;
}

void CE7FrameInfo::SetInfo(CCSpriteBatchNode* pSheet, CCRect rcTexL, CCPoint posL, CCRect rcTexR, CCPoint posR)
{
    m_eFlag = FT_COPY ;

    m_pLeft = CCSprite::spriteWithBatchNode(pSheet, rcTexL) ;
//    m_pLeft->setAnchorPoint(CCPointMake(0, 0)) ;
    m_pLeft->setPosition(posL) ;
    m_pLeft->setIsVisible(false) ;
    pSheet->addChild(m_pLeft) ;

    m_pRight = CCSprite::spriteWithBatchNode(pSheet, rcTexR) ;
//    m_pRight->setAnchorPoint(CCPointMake(0, 0)) ;
    m_pRight->setPosition(posR) ;
    m_pRight->setIsVisible(false) ;
    pSheet->addChild(m_pRight) ;
}

void CE7FrameInfo::Show()
{
    switch (m_eFlag)
    {
        case FT_NORMAL:
        {
            m_pInfo->setIsVisible(true) ;
        } break ;
        case FT_SPRITE:
        {
            m_pItem->setIsVisible(true) ;
            m_pItem->setPosition(m_pPos) ;
            m_pItem->setRotation(m_fRotate) ;
            m_pItem->setScale(m_fScale) ;
            ((CCSprite*)m_pItem)->setOpacity(m_bAlpha) ;
        } break ;
        case FT_COPY:
        {
            m_pLeft->setIsVisible(true) ;
            m_pRight->setIsVisible(true) ;
        } break ;
        default:
            break;
    }
}

void CE7FrameInfo::Hide()
{
    switch (m_eFlag)
    {
        case FT_NORMAL:
        {
            m_pInfo->setIsVisible(false) ;
        } break ;
        case FT_SPRITE:
        {
            // nothing.
//            m_pItem->setIsVisible(false) ;
        } break ;
        case FT_COPY:
        {
            m_pLeft->setIsVisible(false) ;
            m_pRight->setIsVisible(false) ;
        } break ;
        default:
            break;
    }
}









